package generation.makers;

import generation.scale.Scale;
import util.Utils;

public class MelodyMakerImpl implements MelodyMaker {

	public static String[] generateMelody(int quant, String initialTune, Scale scale){
		String[] tunes = scale.getTunes();
		String currentTune = initialTune;
		String melody[] = new String[quant];
		melody[0] = currentTune;
		for (int i = 1; i < melody.length; i++) {
			String nextTune = calculateNextTune(tunes);
			melody[i] = nextTune;
			currentTune = nextTune;
		}
		return melody;
	}
	
	private static String calculateNextTune(String[] tunes){
		return tunes[Utils.random(tunes.length)];
	}
	
	private static String calculateNextTune(String tune){
		String nextTune = "";
		String tunes[] = calculateTuneChanceOrder(tune);
		double chance = Math.random();
		/*if(chance < 0.3){
			double chance2 = Math.random();
			if(chance2 < 0.5){
				nextTune = tunes[3];
			} else {
				nextTune = tunes[4];
			}
		} else {
			double chance2 = Math.random();
			if (chance2 < (1.0f/3)){
				nextTune = tunes[0];
			} else if(chance2 < (2.0f/3)){
				nextTune = tunes[1];
			} else {
				nextTune = tunes[2];
			}
		}
		return nextTune;*/
		return tunes[Utils.random(tunes.length)];
	}

	private static String[] calculateTuneChanceOrder(String tune){
		String[] tunes = new String[5];
		return tunes;		
	}	

}
